﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ITSM.Service;
namespace ITSM.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class CreateEntityController : ControllerBase
    {
        private readonly ILogger<CreateEntityController> _logger;
        private readonly IHostEnvironment _hostEnvironment;
        private readonly IEntity _entity;
        public CreateEntityController(ILogger<CreateEntityController> logger, IHostEnvironment hostEnvironment, IEntity entity)
        {
            _logger = logger;
            _hostEnvironment = hostEnvironment;
            _entity = entity;
        }
        [HttpGet]
        public bool Get(string tableName)
        {
            string filePath = _hostEnvironment.ContentRootPath[.._hostEnvironment.ContentRootPath.LastIndexOf("\\")];
            filePath = filePath[..filePath.LastIndexOf("\\")];
            filePath += "\\ITSM.Model\\Entity\\";
            return _entity.CreateEntity(tableName, filePath);
            //return IEntity.CreateEntity(tableName, _hostEnvironment.ContentRootPath);
        }
    }
}
